package com.hcb.fragment;

import com.hcb.app911.RegisterActivity;

import android.app.DatePickerDialog;
import android.app.Dialog;
import android.support.v4.app.DialogFragment;
import android.os.Bundle;
import android.widget.DatePicker;

public class DatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {

	RegisterActivity regis;
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		regis = (RegisterActivity)getActivity();
		// Create a new instance of DatePickerDialog and return it
		return new DatePickerDialog(getActivity(), this, regis.requestedDateAndTime.getYearInt(), regis.requestedDateAndTime.getMonthInt(), regis.requestedDateAndTime.getDayInt());
	}
	
	public void onDateSet(DatePicker view, int year, int month, int day) {
		regis.requestedDateAndTime.setYearInt(year);
		regis.requestedDateAndTime.setMonthInt(month);
		regis.requestedDateAndTime.setDayInt(day);
		
		String dateString = regis.requestedDateAndTime.getDateString();
		regis.updateDateDisplay(dateString);
	}
}